home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DBio / DREnzyme.h < prev    next >
Text File  |  1996-07-05  |  6KB  |  241 lines

  1. // DREnzyme.h
  2. // d.g.gilbert
  3.  
  4. #ifndef _DREENZYME_
  5. #define _DREENZYME_
  6.     
  7. #include <DObject.h>
  8.  
  9. class DSequence;
  10. class DList;
  11.  
  12.  
  13. #if 0
  14. class DTableClass 
  15. {
  16. public:
  17.     enum  { kUnread, kOkay, kNodata };
  18.     short fState;
  19.     char * fType,* fSection, * fDefaultvalue;
  20.  
  21.     virtual Nlm_Boolean NotAvailable();
  22.     virtual void  Initialize(char* type, char* section, char* defaultvalue);
  23.     virtual void  ReadTable( char* tableFile);
  24.     virtual void  ReadTable( DFile* aFile) = 0;
  25.     virtual void  TableChoice() = 0;
  26. };
  27.  
  28. #endif
  29.  
  30.  
  31. class    DREnzyme : public DObject 
  32. {
  33. public:
  34.     enum {
  35.         kMaxSite = 64, //?? what is max site size
  36.         kCut3EqualsCutpoint = -1  //REnzyme fCut3 flag 
  37.         };
  38.         
  39.     char*            fName            ;        // ? maxlen=10 chars?; /sort
  40.     char*            fSite            ;     //recognition site in nuc codes 
  41.     char*            fVendors    ;     //vendor codes, max 63?
  42.     short            fCutpoint    ;        //cut point from start of fSite 
  43.     short            fCut3from5;        //diff of 3' from 5' cutpoint 
  44.     long            fCutcount    ;        //temp use w/ REMap of seq/sort
  45.     char*            fCoSite        ;     //rev-compl. of fSite, if needed
  46.     short            fCoCutpoint;     //cut point from start of fCoSite 
  47.     
  48.     DREnzyme();
  49.     virtual ~DREnzyme();
  50.     virtual Boolean Parse(char* line);
  51. };
  52.  
  53. class    DREnzymeVendor : public DObject
  54. {
  55. public:
  56.     char        fCode;
  57.     char*        fName;
  58.     
  59.     DREnzymeVendor();
  60.     virtual ~DREnzymeVendor();
  61.     virtual Boolean Parse( char* line);
  62. };
  63.  
  64.  
  65. struct DRECutsItem {
  66.     short            fSeqIndex ;
  67.     DREnzyme*    fREnzyme; 
  68. };
  69.     
  70. //typedef RECutsItem     RECutsList[1];
  71. //typedef RECutsList    *RECutsPtr;
  72.     
  73. class    DREMap : public DObject
  74. {
  75. public:
  76.     enum  { kUnread, kOkay, kNodata };
  77.     static short fState;
  78.     static char     * fType, * fSection, * fDefaultvalue;
  79.     static DList    * fREnzymes;                    // of DREnzyme ?? same as gREnzymes
  80.     static DList    * fREnzymeVendors ;     // of DREnzymeVendor
  81.  
  82.     static  void FreeEnzymeList();
  83.     static  Nlm_Boolean NotAvailable();
  84.     static    void Initialize(char* type = "renzyme", char* section = "data",
  85.                                                     char* defaultvalue = "tables:renzyme.table");
  86.     static  void ReadTable( char* tableFile);  
  87.     static  void ReadTable(DFile* aFile);
  88.     static  void TableChoice();
  89.     
  90.     DSequence     * fSeq, * fCoSeq;  //Reverse+Complement of fSeq
  91.     DRECutsItem * fSeqCuts;               
  92.     long    fMaxcuts, fCutcount;
  93.     short    fCuttersCount;             //# zymes that cut
  94.     char    fTargetbase;
  95.     
  96.     DREMap();
  97.     virtual ~DREMap(); 
  98.     //DObject* Clone(); 
  99.  
  100.     void FreeTempData(); 
  101.     void MapSeq( DSequence* aSeq);
  102.     void CutsAtBase( short atBase, short& firstCut, short& nCuts);
  103.  
  104. private:
  105.     void HuntCut( short n, short x, short& jlo);
  106.     long QuickSearch( Nlm_Boolean first, char* target, long targlen, 
  107.                                         char* source, long sourcelen);
  108.     void SearchStrand( DSequence* bSeq, char* aTarget, char* sourcebits, long sourcelen,
  109.                                             DREnzyme* zyme, short cutAdd, long& zymecuts);
  110.     void FindCuts( DREnzyme* zyme, char* sourcebits, long sourcelen);
  111. };
  112.  
  113.  
  114.  
  115.  
  116. struct CodonStat
  117. {
  118.     char     codon[4];         //3 letter nucleic codon
  119.     char    amino;                 //1 letter amino name
  120.     float numPerK;             //frequency in 10000
  121.     
  122.     CodonStat( char* codn = "---", char ami = 'N', float numk = 0);
  123. };
  124.  
  125. class DCodons 
  126. {
  127. public:
  128.     enum  { kUnread, kOkay, kNodata };
  129.     static short fState;
  130.     static char * fType,* fSection, * fDefaultvalue;
  131.     static short fStartcodon;
  132.     static CodonStat *fCodons;
  133.  
  134.     static Nlm_Boolean NotAvailable();
  135.     static void  Initialize(char* type = "codon", char* section = "data",
  136.                                                     char* defaultvalue = "tables:codon.table");
  137.     static void  ReadTable( char* tableFile);
  138.     static void  ReadTable( DFile* aFile);
  139.     static void  TableChoice();
  140.     
  141.     static Boolean badindex(short i) { return (fState != kOkay || i<0 || i>63); }
  142.     static char* codon(short i)   { if (badindex(i)) return "   "; else return fCodons[i].codon; }
  143.     static char  amino(short i)   { if (badindex(i)) return ' '; else return fCodons[i].amino; }
  144.     static float numPerK(short i) { if (badindex(i)) return 0; else return fCodons[i].numPerK; }
  145.     static const char* FindBestCodon( char matchamino);
  146.     static char* startcodon() { 
  147.         if (badindex(fStartcodon)) return "ATG"; 
  148.         else return fCodons[fStartcodon].codon; 
  149.         }
  150.     static char  startamino() { 
  151.         if (badindex(fStartcodon)) return 'M'; 
  152.         else return fCodons[fStartcodon].amino; 
  153.         }
  154. };
  155.  
  156.  
  157. typedef unsigned long baseColors['~'-' '+1];
  158.  
  159. // ?? turn this into a generic class for reading data files ??
  160. class DBaseColors
  161. {
  162. public:
  163.     enum  { kUnread, kOkay, kNodata };
  164.     static short fState;
  165.     static char * fType,* fSection, * fDefaultvalue;
  166.     static baseColors gAAcolors;
  167.     static baseColors gNAcolors;
  168.  
  169.     static Nlm_Boolean NotAvailable();
  170.     static void  Initialize(char* type = "color", char* section = "data",
  171.                                                     char* defaultvalue = "tables:color.table");
  172.     static void  ReadTable( char* tableFile);
  173.     static void  ReadTable( DFile* aFile);
  174.     static void  TableChoice();
  175.     
  176.     static void  InitColors();
  177. };
  178.  
  179.  
  180.  
  181. class DSeqStyle : public DObject {
  182. public:
  183.     enum { kFramenone, kFramebox, kFrameoval, kFramerrect };
  184.     enum { kFrameSolid, kFrameDotted, kFrameDashed, kFrameDark, kFrameMedium, kFrameLight };
  185.     char    * name, * description;
  186.     char    * fontname;
  187.     short        fontsize;
  188.     Nlm_FonT    font;
  189.     Boolean    bold:1;
  190.     Boolean    italic:1;
  191.     Boolean    uline:1;
  192.     Boolean    uppercase:1;
  193.     Boolean    lowercase:1;
  194.     Boolean dofontpat:1;
  195.     Boolean    dofontcolor:1;
  196.     Boolean    dobackcolor:1;
  197.     Boolean    doframecolor:1;
  198.     Boolean    invertcolor:1;
  199.     ulong        fontcolor;
  200.     ulong        backcolor;
  201.     ulong        framecolor;
  202.     short        framestyle;
  203.     char        repeatchar;
  204.     char        fontpattern[8];
  205.     short        frame;
  206.  
  207.     DSeqStyle();
  208.     virtual ~DSeqStyle(); // delete font, fontname
  209.     void GetFont();
  210.     void ClearDrawing();
  211.     DObject* Clone();
  212. };
  213.  
  214. class DStyleTable 
  215. {
  216. public:
  217.     enum  { kUnread, kOkay, kNodata };
  218.     static short fState;
  219.     static char * fType,* fSection, * fDefaultvalue;
  220.     static DList* fStyles;  // list of DSeqStyle
  221.     static DSeqStyle fLaststyle;
  222.     static char        fLastch;
  223.     static char * fToprow;
  224.     static long      fToprowlen;
  225.     
  226.     static Nlm_Boolean NotAvailable();
  227.     static void  Initialize(char* type = "seqmasks", char* section = "data",
  228.                                                     char* defaultvalue = "tables:seqmasks.table");
  229.     static void ReadTable( char* tableFile);
  230.     static void ReadTable( DFile* aFile);
  231.     static void TableChoice();
  232.     static void StartDraw(char* toprowbases, long maxrow);
  233.     static void EndDraw();
  234.     static void DrawBaseWithStyle( char ch, long baseindex, short maskval,     
  235.                                                                       Nlm_RecT&    crec, short atrow);
  236. };
  237.  
  238.     
  239. #endif
  240.  
  241.